package main

import (
	"fmt"
	"strings"
)

//类型别名
//type(
//	byte int8
//	rune int32
//	s string
//)
func main() {
	//str()
	chineseReverse()

	var a int = 65

	b := string(a)

	fmt.Println(b)

	replaceStr()
}

func str()  {
	var str = "hello"
	fmt.Printf("str[0]=%c len(str)=%d\n", str[0], len(str))

	var byteSlice []byte
	byteSlice = []byte(str)
	byteSlice[2] = '0'
	str = string(byteSlice)

	fmt.Println("after modify:", str)

	str = "中问123"
	fmt.Printf("last:len(str)=%d\n", len(str))

	//rune类型⽤用来表示utf8字符
	var b = '中'
	fmt.Printf("b=%c\n", b)

	var runeSlice []rune
	runeSlice = []rune(str)
	fmt.Printf("str 长度:%d, len(str)=%d\n", len(runeSlice), len(str))
}

func chineseReverse(){
	var str = "北京8866sss"
	fmt.Println(len(str))

	var bytes []byte = []byte(str)

	for i := 0; i < len(str)/2;i++ {
		tmp := bytes[len(str)-i-1]
		bytes[len(str)-i-1] = bytes[i]
		bytes[i] = tmp
	}

	str = string(bytes)
	fmt.Println(str)
}

func replaceStr(){
	THUMBNAIL_IMG := "<img src='{}' style='width: 80px;'>"
	newStr := strings.Replace(THUMBNAIL_IMG,"{}","aaa",-1)
	fmt.Println(newStr)
}